<template>
  <div>
    <h2>商品详情组件</h2>
      商品ID：{{product.name}}
      商品名称：{{product.name}}
      商品价格：{{product.price}}
  </div>
</template>
<script>
export default {
  data () {
    return {
      product: {}
    }
  },
  mounted () {
     this.getProduct()
  },
  methods: {
      getProduct() {
          console.log('发送请求')
          var id = this.$route.params.id
          var self = this
         this.$http.get('api/product/'+id).then( (response) => {
             self.product = response.body.data
         })
      }
  }
}
</script>
